<?php
namespace app\admin\logic;

class Brandlogic
{

    // 品牌留值
    public static function getDataBrand($param)
    {

        $data = [
            'keywords'=>isset($param['keywords'])?$param['keywords']:'',
            'if_show'=>isset($param['if_show'])?$param['if_show']:[],
            'recommended'=>isset($param['recommended'])?$param['recommended']:'',
            'logo'=>isset($param['logo'])?$param['logo']:[],
        ];

        return $data;
    }

    // 品牌where拼接
    public static function getWhereBrand($param)
    {

        $where=[];
        $whereOr=[];
        if (isset($param['keywords']) && !empty($param['keywords'])){
            $where[] = ['brand_name','like','%'.$param['keywords'].'%'];
        }
        if (isset($param['if_show']) && count($param['if_show'])==1){
            $where[]=['if_show','in',$param['if_show']];
        }
        if (isset($param['recommended']) && $param['recommended']<>''){
            $where[]=['recommended','=',$param['recommended']];
        }

        if (isset($param['logo']) && $param['logo']<>''){
            $em=implode($param['logo']);
            echo $em;
            if ($em=='1'){
                $where[]=['brand_logo','<>',''];
            }
            if ($em=='0'){
                $whereOr[]=['brand_logo','=',''];
                $whereOr[]=['brand_logo','=',null];
            }

        }


        return [$where,$whereOr];

    }

    // 品牌
    public static function getBrandData($param)
    {
        $data = [
            'brand_name'=>$param['bid'],
            'recommended'=>$param['recommendeds'],
            'if_show'=>$param['show'],
            'tag'=>$param['name'],
            'sort_order' =>$param['sort'],
        ];

        return $data;
    }

}